﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

namespace DiskGallery
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {

        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {
            Exception errorException = Server.GetLastError();

            string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase).ToString();
            string file = directory.Substring(6) + "\\Log.txt";
            string strLogin = DateTime.Now + ": Error: " +errorException.Message+"\r\n";
            using (StreamWriter outfile = File.AppendText(file))
            {
                outfile.WriteLine(strLogin);
            }
        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}